package iad.dao;

import iad.dto.IrisDTO;
import iad.neuralnet.attribute.Attribute;
import iad.neuralnet.attribute.iris.IrisResult;
import iad.neuralnet.attribute.iris.PetalLength;
import iad.neuralnet.attribute.iris.PetalWidth;
import iad.neuralnet.attribute.iris.SepalLength;
import iad.neuralnet.attribute.iris.SepalWidth;
import iad.parser.IrysParser;

import java.io.File;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class IrisDAOImpl implements IrisDAO {

	final static Logger logger = LoggerFactory.getLogger(IrisDAOImpl.class);
	private IrisDTO irisDTO;
	
	public IrisDAOImpl(){
		super();
		this.irisDTO = this.selectAll();
	}
	
	private IrisDTO selectAll() {
		logger.info("selectAll in IrisDAO");
		File f = new File("./data/iris.data");
		return IrysParser.parse(f);	
	}
	
	@Override
	public List<Attribute<SepalLength>> getSepalLengthColumnList(){
		return irisDTO.getSepalLengthColumn();
	}	
	
	@Override
	public List<Attribute<SepalWidth>> getSepalWidthColumnList(){
		return irisDTO.getSepalWidthColumn();
	}	
	
	@Override
	public List<Attribute<PetalLength>> getPetalLengthColumnList(){
		return irisDTO.getPetelLengthColumn();
	}	
	
	@Override
	public List<Attribute<PetalWidth>> getPetalWidthColumnList(){
		return irisDTO.getPetalWidthColumn();
	}	
	
	@Override
	public List<Attribute<IrisResult>> getIrisResultColumnList(){
		return irisDTO.getIrisResultColumn();
	}	
	
	
//	@Override
//	public List<Attribute<SepalLength>> selectSepalLenghtAttributes(){
//		List<List<Attribute>> allAttr = selectAll();
//		List<Attribute<SepalLength>> sepalList = new ArrayList<Attribute<SepalLength>>();
//		for(int i=0; i<allAttr.size(); i++){
//			List<Attribute> row = allAttr.get(i);
//			for(int j=0; j<row.size(); j++){
//				Attribute a = row.get(j);
//				if (a instanceof SepalLength){
//					Attribute<SepalLength> slAttr = (Attribute<SepalLength>) a;
//					sepalList.add(slAttr);					
//				}
//			}
//		}
//		return sepalList;
//	}

}
